# run.py
import uvicorn
import sys
import os

if __name__ == "__main__":
    try:
        print("🔧 正在启动服务...")
        print("📌 模块搜索路径:", sys.path)

        # 确保项目根目录在 sys.path 中ip
        current_dir = os.path.dirname(os.path.abspath(__file__))
        if current_dir not in sys.path:
            sys.path.insert(0, current_dir)

        uvicorn.run(
            "backend.main:app",
            host="0.0.0.0",
            port=8000,
            reload=True,
            workers=1
        )
    except Exception as e:
        print(f"❌ 启动失败: {e}")
        raise